<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>数组字符串最长前缀</title>
	</head>
	<body>
		<script>
			var arr = ['boxbig','boxbshadow','boxbeach'];
			function sub(objs){
				if(objs.length==0){return ''};
				var newArr=objs[0];
				for(var obj of objs){
					var toask = '';
					for(var i=0,j=0;i<newArr.length&j<obj.length;i++,j++){
						if(newArr[i]==obj[j]){
							toask+=obj[j];
						}else{
							break;
						}
					}
					newArr = toask;
				}
				return newArr;
			}
			console.log(sub(arr));
		</script>
	</body>
</html>
